package com.malphite.mongodemo.mongo;

import com.mongodb.client.MongoCollection;
import com.mongodb.client.MongoDatabase;
import com.mongodb.client.model.Filters;
import org.bson.Document;
import org.bson.conversions.Bson;

public class Mongo2Delete {

    public static void main(String[] args) {
        //{ "delete" : "places", "ordered" : true, "$db" : "test", "deletes" : [{ "q" : { "name" : "home" }, "limit" : 1 }] }
        MongoDatabase test = Mongo1Connection.getDataBase("test");
        MongoCollection<Document> collection = test.getCollection("places");
        Bson eq = Filters.eq("name", "home");
        long deletedCount = collection.deleteOne(eq).getDeletedCount();
        System.out.println(deletedCount);
    }

}
